home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE21
/
EX7.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-29
|
2KB
|
48 lines
#include <genstub.c>
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static SYSTEMTIME stSystemTimeEntry;
switch (uMsg)
{
case WM_CREATE:
GetSystemTime( &stSystemTimeEntry );
return( DefWindowProc(hWnd, uMsg, wParam, lParam ) );
case WM_COMMAND:
switch( LOWORD( wParam ) )
{
case IDM_TEST: // Add an hour to the clock.
{
SYSTEMTIME st;
TCHAR szBuffer[128];
GetLocalTime( &st );
// Add one hour.
st.wHour++;
if (st.wHour==23)
st.wHour = 0; // Wrap to next day.
SetLocalTime( &st );
// Display new local time.
wsprintf(szBuffer, "The new time is %d:%d:%d.%d",
st.wHour, st.wMinute, st.wSecond,
st.wMilliseconds );
MessageBox( hWnd, szBuffer, "Added One Hour",
MB_OK );
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
break;
}
break;
case WM_DESTROY:
SetSystemTime( &stSystemTimeEntry );
PostQuitMessage( 0 );
break;
default:
return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
}
return( NULL );
}